package com.gin.no_gay_alliance.viewmodel;

import com.gin.nga.enums.SubForumStatus;
import com.gin.nga.response.field.SubForum;
import com.gin.nga.utils.ForumIconUtils;

import java.util.List;

/**
 * 子版面数据
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/8/31 11:30
 **/
public class SubForumModel extends EntryData {
    /**
     * 镜像id
     */
    public Long mirrorId;
    /**
     * 是否被选中
     */
    public boolean selected;
    /**
     * 是否允许选中
     */
    public boolean selectable;

    public SubForumModel(SubForum subForum) {
        this.id = subForum.getId();
        this.type = subForum.getType();
        this.mirrorId = subForum.getMirrorId();
        this.name = subForum.getName();
        this.icon = ForumIconUtils.getBigIconUrl(id);

        List<SubForumStatus> statuses = subForum.getStatuses();
        if (statuses != null) {
            selectable = statuses.contains(SubForumStatus.SELECTABLE);

            if (statuses.contains(SubForumStatus.SELECTED_EXTRA)) {
                selected = true;
            } else if (statuses.contains(SubForumStatus.NOT_SELECTED)) {
                selected = false;
            }
        }
    }

}
